import java.util.Scanner;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @email 1600337300@qq.com
 * @date 2021-08-22 20:38
 */
public class ExamTencent2021082203 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int n = scanner.nextInt();
            int w = scanner.nextInt();
            int[] a = new int[n];
            int[][] dp = new int[n][n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
                dp[i][i] = 1;
            }

            long ans = 0;
            for (int i = n - 1; i >= 0; i--) {
                ans = (2 * ans + a[i]) % 1000000007;
            }
            System.out.println(ans);
        }
    }
}
